package com.aaa.service.sds.impl;

import cn.hutool.core.util.ObjectUtil;
import com.aaa.dao.ReturnRecordsDao;
import com.aaa.dao.sds.ViewTestResultSdsDao;
import com.aaa.entity.ReturnRecords;
import com.aaa.entity.system.PageEnty;
import com.aaa.entity.sds.ViewTestResultSds;
import com.aaa.entity.sds.ViewTestResultSdsTotal;
import com.aaa.entity.system.PageOrder;
import com.aaa.service.sds.ViewTestResultSdsService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * (ViewTestResultSds)表服务实现类
 *
 * @author makejava
 * @since 2022-09-02 09:49:58
 */
@Service("viewTestResultSdsService")
public class ViewTestResultSdsServiceImpl implements ViewTestResultSdsService {
    @Autowired
    ViewTestResultSdsDao viewTestResultSdsDao;


    @Autowired
    private ReturnRecordsDao returnRecordsDao;

    @Override
    public Page<ReturnRecords> getReturnRecords(PageOrder pageOrder, ReturnRecords records) {
        //拿出pageOrder里面的所有数据
        PageHelper.startPage(pageOrder.getPage(), pageOrder.getLimit());
        //判断数据是否为空
        if (ObjectUtil.isNotEmpty(pageOrder.getField())) {
            PageHelper.orderBy(pageOrder.getFieldOrder());
        }
        return (Page<ReturnRecords>) returnRecordsDao.getReturnRecordsSDS(records);
    }

    @Override
    public int insertReturn(ReturnRecords records) {
        return returnRecordsDao.insertSDS(records);
    }
    @Override
    public Page queryAllViewSdsPage(PageEnty pageEnty, ViewTestResultSds viewTestResultSds) {
        PageHelper.startPage(pageEnty.getPage(),pageEnty.getLimit(),pageEnty.orderBy());
        List<Map<String, Object>> mapList = viewTestResultSdsDao.queryAllViewSdsPage(viewTestResultSds);
        Page page= (Page) mapList;
        return page;
    }

    @Override
    public boolean deleteUser(int[] id) {
        return viewTestResultSdsDao.deleteViewSds(id);
    }

    @Override
    public List<ViewTestResultSds> queryById(Integer id) {
        return viewTestResultSdsDao.queryById(id);
    }

    @Override
    public List<ViewTestResultSdsTotal> queryAllSds() {
        return viewTestResultSdsDao.queryAllSds();
    }

    @Override
    public Page<Map<String, Object>> getByTesterId(PageOrder pageOrder, Integer testerId) {
        //拿出pageOrder里面的所有数据
        PageHelper.startPage(pageOrder.getPage(), pageOrder.getLimit());
        //判断数据是否为空
        if (ObjectUtil.isNotEmpty(pageOrder.getField())) {
            PageHelper.orderBy(pageOrder.getFieldOrder());
        }
        return (Page<Map<String,Object>>) viewTestResultSdsDao.getByTesterId(testerId);
    }


}
